<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<head th:include="/base/common_css('test')">
<body>
<div th:include="/base/common_banner"></div>
<!-- Main content starts -->

<div class="content">
    <!-- Sidebar -->
    <div th:include="/base/common_menu"></div>
    <!-- Sidebar
    <div class="sidebar">
        <div class="sidebar-dropdown"><a href="#">Navigation</a></div>

    </div>-->
    <!-- Matter -->
    <div class="mainbar">
        <!-- Page heading -->
        <div th:include="/base/common_pageHeader"></div>

        <div class="matter">
            <div class="container">
                <div class="row">
                    <div class="col-md-6">


                        <div class="widget wgreen">

                            <div class="widget-head">
                                <div class="pull-left">角色编辑</div>
                                <div class="widget-icons pull-right">
                                    <a href="#" class="wminimize"><i class="icon-chevron-up"></i></a>
                                    <a href="#" class="wclose"><i class="icon-remove"></i></a>
                                </div>
                                <div class="clearfix"></div>
                            </div>

                            <div class="widget-content">
                                <div class="padd">

                                    <!-- Form starts.  -->
                                    <form class="form-horizontal" role="form" action="#" method="post">

                                        <div class="modal-body">
                                            <form action="#" method="post"
                                                  enctype="multipart/form-data">
                                                <input class="col-lg-4 form-control " type="hidden" id="roleId"
                                                       th:value="${roleId}">
                                                <div class="form-group">
                                                    <label class="col-lg-4 control-label">角色名</label>
                                                    <div class="col-lg-8">
                                                        <input type="text" th:value="${roleName}" class="form-control"
                                                               id="roleName" placeholder="角色名">
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label class="col-lg-4 control-label">角色描述</label>
                                                    <div class="col-lg-8">
                                                        <input type="text" th:value="${roleDescription}" class="form-control"
                                                               id="roleDescription" placeholder="角色描述">
                                                    </div>
                                                </div>




                                            </form>
                                        </div>

                                    </form>
                                    <div class="modal-footer">
                                        <button type="button" class="col-lg-1 btn-default pull-right"
                                                onclick="cancles()">取消
                                        </button>
                                        <button type="button" onclick="saveRole()"
                                                class="col-lg-1 btn btn-success pull-right">保存
                                        </button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>



<!-- Mainbar ends -->
<div class="clearfix"></div>

</div>
<!-- Content ends -->

<div th:include="/base/common_footer"></div>
<!-- Scroll to top -->
<span class="totop"><a href="#"><i class="icon-chevron-up"></i></a></span>
<!--js????-->
<div th:include="/base/common_js"></div>
<script type="text/javascript">

    function cancles() {
        window.location = "/view/saveRole";
    }

    //保存新增/修改
    function saveRole() {
        var data = {
            'roleId': $('#roleId').val(),
            'roleName': $('#roleName').val(),
            'roleDescription': $('#roleDescription').val(),
        }
        $.ajax({
            url: "/view/saveOrupdateRole",
            type: "POST",
            dataType: "json",
            data: data,
            success: function (data) {

                if (data.data) {
                    window.location.href = "/view/roleList?pageNumber=1&pageSize=10";
                }
            },
        });

    }


</script>

</body>
</html>